import { WxApp } from '@/interfaces';

export interface IAppModelState {
  title: string;
  sideMenuOpen: boolean;
  menu: any[];
  loginExpired: boolean;
  loginExited: boolean;
  user: any | null;
}

const model: WxApp.ModelObject<IAppModelState> = {
  namespace: 'app',
  state: {
    title: 'DLJ Platform',
    sideMenuOpen: false,
    menu: [],
    loginExpired: false,
    loginExited: false,
    user: null,
  },
  subscriptions: {
    setup(api) {
      // api.history
      // 检测是否存在 token
    },
  },
  effects: {
    *boot(action, command) {},
    *getUserInfo(action, command) {},
    *logout(action, command) {},
  },
  reducers: {
    load(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
export default model;
